﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DynORM.Interfaces
{
    public class CheckIntegrityResult
    {
        private bool result;
        private string reason;
        private CheckIntegrityResult nestedCheckIntegrityResult;

        public CheckIntegrityResult(bool result, string reason, CheckIntegrityResult nestedCheckIntegrityResult)
        {
            this.result = result;
            this.reason = reason;
            this.nestedCheckIntegrityResult = nestedCheckIntegrityResult;
        }

        public CheckIntegrityResult(bool result, string reason)
            : this(result, reason, null)
        { }

        public bool Result
        {
            get
            {
                return this.result;
            }
        }
        public string Reason
        {
            get
            {
                return this.reason;
            }
        }
        public CheckIntegrityResult NestedCheckIntegrityResult
        {
            get
            {
                return this.nestedCheckIntegrityResult;
            }
        }

        #region Value-based equality semantics implementation
		public override bool Equals(object obj)
        {
            bool result = false;
            CheckIntegrityResult that = obj as CheckIntegrityResult;
            if (that != null)
                if (this.result == that.result && String.Compare(this.reason, that.reason, false) == 0)
                    result = true;

            return result;
        }

        public override int GetHashCode()
        {
            return this.result.GetHashCode();
        }

        public static bool operator ==(CheckIntegrityResult op1, CheckIntegrityResult op2)
        {
            if (object.ReferenceEquals(op1, null))
                return false;
            else
                return op1.Equals(op2);
        }

        public static bool operator !=(CheckIntegrityResult op1, CheckIntegrityResult op2)
        {
            if (object.ReferenceEquals(op1, null))
                return false;
            else
                return !op1.Equals(op2);
        }

	    #endregion
    }

}
